From a631056808029202ebae32d51c611bd73ddf5144 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 14 May 2013 23:18:05 -0400 Subject: [PATCH] Add a --directory option to accessibility-dump This will be used to tell it where its test data resides when running the a11y tests installed. --- tests/a11y/accessibility-dump.c | 36 +++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/tests/a11y/accessibility-dump.c b/tests/a11y/accessibility-dump.c index 8d4b2b1c67..62541a14fa 100644 --- a/tests/a11y/accessibility-dump.c +++ b/tests/a11y/accessibility-dump.c @@ -819,17 +819,49 @@ add_tests_for_files_in_directory (GFile *dir) g_list_free_full (files, g_object_unref); } +static char *arg_base_dir = NULL; + +static const GOptionEntry test_args[] = { + { "directory", 'd', 0, G_OPTION_ARG_FILENAME, &arg_base_dir, + "Directory to run tests from", "DIR" }, + { NULL } +}; + +static gboolean +parse_command_line (int *argc, char ***argv) +{ + GError *error = NULL; + GOptionContext *context; + + context = g_option_context_new ("- run GTK accessibility tests"); + g_option_context_add_main_entries (context, test_args, NULL); + g_option_context_set_ignore_unknown_options (context, TRUE); + + if (!g_option_context_parse (context, argc, argv, &error)) + { + g_print ("option parsing failed: %s\n", error->message); + return FALSE; + } + + gtk_test_init (argc, argv); + + return TRUE; +} + int main (int argc, char **argv) { - gtk_test_init (&argc, &argv); + if (!parse_command_line (&argc, &argv)) + return 1; if (argc < 2) { const char *basedir; GFile *dir; - if (g_getenv ("srcdir")) + if (arg_base_dir) + basedir = arg_base_dir; + else if (g_getenv ("srcdir")) basedir = g_getenv ("srcdir"); else basedir = "."; -- 2.30.2